<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class testController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        echo '卡卡 丢去的好补回来';
    }

    public function request(Request $request)
    {
        // $input = $request->input('name');
        // echo '你好——我的名字是'.$input;
        // if(!$request->is('request/*')){
        //    echo 'error';
        // }
        // $url = $request->path();
        // $urlt = $request->url();
        // echo $url;
        // echo '<br>';
        // echo $urlt;
        // echo '<br>';
        // echo $request->isMeethod('get');
        // echo '<br>';
        // echo $request->method();
        //echo $request->has('test');
        //$name = $request->input('name','kaka');
       // echo $name;
        //echo '<br>';
       // echo $request->input('test.name.name.0');
        // print_r($request->only('name'));
        // print_r($request->all('name'));
        // print_r($request->except('name'));
        $request->flash();
    }

    public function flash(Request $request){
        //$request->flash();
        //return redirect('/test/old')->withInput();
        return redirect('test/old')->withInput();
    }

    public function old(Request $request)
    {
        //$lastRequest = $request->old();
        $result = $request->old();
        print_r($result);
    }

    // public function getCookie(Request $request)
    // {
    //     $cookie = $request->cookie('name');
    //     echo $cookie;
    // }

    // public function getAddCookie()
    // {
    //     $response = new Response();
    //     $response->withCookie(cookie('name','kaka',1));
    //     return $response;
    // }

    // public function fileUpload()
    // {
    //     $postUrl = '/request/fileupload';
    //     $csrf_filed=csrf_filed();
    //     $html = CREATE <form action='$posturl' method='POST' enctype="multipart/form-data">
    //     $csrf_filed
    //     <input type="file" name='file'><br/><br/>
    //     <input type='submit' value='提交'/>
    //     <form/>
    //     CREATE;
    //         return $html;
    // }

    public function setCookie()
    {   
        // cookie添加操作 直接设置cookie
        //\Cookie::queue('name','kaka',1);

        //在响应数据时同时设置cookie 
        return response('')->withCookie('name','ccccccNeil',-1);                      
    }

    public function getCookie(Request $request)
    {
        echo $request->cookie('name');
         //echo \Cookie::get('name');
    }
    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
        echo 'kaka';
        echo route('demo');
        //return redirect('demo');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
        //echo '失去的就不一样了'.$id;
        dd ($request);
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        echo '失去的就不一样了'.$id;
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
